275. H 指数 II
https://leetcode.cn/problems/h-index-ii/description
- 难度:中等
- 提交时间:2023.10.30 18:40
- 12ms 击败 93.85%使用 Go 的用户
- 6.68MB 击败 6.92%使用 Go 的用户
func hIndex(citations []int) int {
n := len(citations)
maxH := 0
for i, item := range citations {
if item == 0 {
continue
}
if item < n-i {
continue
}
m := min(item, n-i)
if m < maxH {
break
}
maxH = max(m, maxH)
}
return maxH
}
func max(x, y int) int {
if x > y {
return x
}
return y
}
func min(x, y int) int {
if x < y {
return x
}
return y
}